home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / dev / misc / LEDA_gene.lha / LEDA-3.1c-generic / incl / LEDA / stream.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-05  |  1.9 KB  |  92 lines

  1. /*******************************************************************************
  2. +
  3. +  LEDA  3.1c
  4. +
  5. +
  6. +  stream.h
  7. +
  8. +
  9. +  Copyright (c) 1994  by  Max-Planck-Institut fuer Informatik
  10. +  Im Stadtwald, 6600 Saarbruecken, FRG     
  11. +  All rights reserved.
  12. *******************************************************************************/
  13.  
  14.  
  15. #ifndef LEDA_STREAM_H
  16. #define LEDA_STREAM_H
  17.  
  18. #include <LEDA/basic.h>
  19.  
  20.  
  21. #if defined (__ZTC__) 
  22.  
  23. #include <fstream.hpp>
  24. #include <strstream.hpp>
  25.  
  26. /* bug in ZORTECH library ? 
  27.    cannot derive from streams */
  28.  
  29. typedef ifstream   file_istream;
  30. typedef ofstream   file_ostream;
  31. typedef istrstream string_istream;
  32. typedef ostrstream string_ostream;
  33.  
  34.  
  35. #else  
  36.  
  37. #include <fstream.h>
  38. #include <strstream.h>
  39.  
  40. struct file_ostream : public ofstream 
  41. { file_ostream(string s) : ofstream(~s) {}
  42.   file_ostream(char*  s) : ofstream(s) {}
  43.   bool open(string s)  { ofstream::open(~s); return !fail(); }
  44.  };
  45.  
  46. struct file_istream : public ifstream
  47. { file_istream(string s) : ifstream(~s) {}
  48.   file_istream(char*  s) : ifstream(s) {}
  49.   bool open(string s)  { ifstream::open(~s); return !fail(); }
  50.  };
  51.  
  52. struct string_istream : public istrstream 
  53. { string_istream(string s) : istrstream(~s) {}
  54.   string_istream(char* s)  : istrstream(s) {}
  55.   string_istream(int argc, char** argv) 
  56.                            : istrstream(~string(argc,argv)) {}
  57.  
  58.  };
  59.  
  60.  
  61. struct string_ostream : public ostrstream 
  62. { string_ostream() {};
  63.   string str()     { return ostrstream::str(); };
  64.  };
  65.  
  66.  
  67. #endif
  68.  
  69.  
  70. #if defined(__MSDOS__)
  71.  
  72. typedef file_ostream cmd_ostream;
  73. typedef file_istream cmd_istream;
  74.  
  75. #else
  76.  
  77. struct cmd_ostream : public ofstream 
  78. { cmd_ostream(string cmd) : ofstream(fileno(popen(~cmd,"w"))) {}
  79.   cmd_ostream(char*  cmd) : ofstream(fileno(popen(cmd,"w"))) {} 
  80.  };
  81.  
  82. struct cmd_istream : public ifstream 
  83. { cmd_istream(string cmd) : ifstream(fileno(popen(~cmd,"r"))) {}
  84.   cmd_istream(char*  cmd) : ifstream(fileno(popen(cmd,"r"))) {} 
  85.  };
  86.  
  87. #endif
  88.  
  89. #endif
  90.  
  91.